﻿using System;
using System.Windows.Input;

namespace Modules.Core {
    public class ExecutableCommand : ICommand{
        private Action<object> m_executeAction;
        public event EventHandler CanExecuteChanged;

        public ExecutableCommand(Action<object> action) {
            this.m_executeAction = action;
        }

        public ExecutableCommand(Action action) {
            Action<object> action2 = null;
            if(action2 == null) {
                action2 = new Action<object>(p => action());
            }
            this.m_executeAction = action2;
        }

        public virtual bool CanExecute(object parameter) {
            return true;
        }
        public void Execute(object parameter) {
            this.m_executeAction(parameter);
        }
        public void RaiseCanExecuteChanged(object semder, EventArgs e) {
            if(this.CanExecuteChanged != null) {
                this.CanExecuteChanged(semder, e);
            }
        }
    }
}
